<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Api\ApiController;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
use QCloud\Cos\Api;

class ImagesController extends ApiController
{

    public function __construct()
    {
        $this->middleware('auth:api');
    }

    /**
     * @api {post} /images 上传图片
     * @apiName Images upload
     * @apiGroup Image
     *
     * @apiParam {File} image 图片.
     *
     * @apiVersion 1.0.0
     * @apiSampleRequest /api/images
     *
     *
     */
    public function store(Request $request){

        $this->validate($request,[
            'image' => 'required|image'
        ]);

        $file = $request->file('image');

        $res = Storage::disk('qcloud')->put('images',$file);

        $url = Storage::disk('qcloud')->url($res);

        return $this->success(compact('url'));


    }



}
